package com.pactera.madp.cp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pactera.madp.common.core.util.R;
import com.pactera.madp.cp.api.bo.IndexMsgBO;
import com.pactera.madp.cp.api.dto.contact.ContactPageDTO;
import com.pactera.madp.cp.api.dto.contact.MsgToEmployeeDTO;
import com.pactera.madp.cp.api.dto.contact.SyncContactDetailsTendencyDTO;
import com.pactera.madp.cp.api.dto.contact.UpdateContactDto;
import com.pactera.madp.cp.api.dto.wxGZH.WxGZHDto;
import com.pactera.madp.cp.api.em.permission.ReqPerEnum;
import com.pactera.madp.cp.api.em.workcontact.EventEnum;
import com.pactera.madp.cp.api.entity.WorkContactEntity;
import com.pactera.madp.cp.api.model.workcontact.ContactData;
import com.pactera.madp.cp.api.model.workcontact.GetContactInfoResponse;
import com.pactera.madp.cp.api.model.workcontact.GetContactRequest;
import com.pactera.madp.cp.api.vo.ManagerViewCustomerVO;
import com.pactera.madp.cp.api.vo.contact.*;

import java.util.List;
import java.util.Map;

public interface IContactService extends IService<WorkContactEntity> {

    /**
     * 获取客户列表
     * @param parem
     * @param empId
     * @param corpId
     * @param perEnum
     */
    Page<List<ContactData>> getContactPage(Page page, GetContactRequest parem, int empId, int corpId, ReqPerEnum perEnum);

    ContactMessageVxVO getContactInfoWx(String wxExternalUserid,String wxUserId);

    ContactMessageVxVO getContactInfoWxDelete(String wxExternalUserid,String wxUserId);

    GetContactInfoResponse getContactInfo(Integer contactId, Integer empId, Integer corpId);

    boolean updateBusinessNo(Integer empId, Integer contactId, String businessNo);

    boolean updateContact(UpdateContactDto parem, Integer corpId, Integer empId);

    boolean synContact(Integer corpId);

    boolean insertAllContact(List<WorkContactEntity> contacts);

    boolean insertAllContact(List<WorkContactEntity> contacts,Integer corpId);

    boolean insertContact(WorkContactEntity contact);

    Page<List<ContactLossVO>> getlossContact(Integer corpId, List<Integer> empId, Page page);

    String getWXExternalUserid(int contactId);

    Integer getContactId(String wxExternalUserid,Integer corpId);

    void addExternalContact(String wxCorpId, String externalUserid,String userId,String welcomeCode,String state);

    void editExternalContact(String externalUserid, String userId);

    void deleteExternalContact(String externalUserid, String userId,String source);

    void externalContactDeleteEmployee(String externalUserid, String userId);

    void tagSaveContact(String externalUserid, String userId,String name);

    void tagDeleteContact(String externalUserid, String userId,String name);

    void userTagSaveContact(String externalUserid, String userId,String name);

    void userTagDeleteContact(String externalUserid, String userId,String name);

    Integer insertWXSynContact(JSONObject contactJson, Integer corpId);

    ContactDetailVO getContactDetailByWxExternalUserId(String wxExternalUserid);

    Page<List<ContactTrackVO>> getContactTrackByContactId(Integer contactId,Page page,Integer employeeId);

    /**
     * 侧边栏调用接口
     *
     * @param wxExternalUserid
     * @param page
     * @return
     */
    Page<List<ContactTrackVO>> getContactTrackByContactIdWechat(String wxUserId,String wxExternalUserid,Page page);

    /**
     * 客户详情客户动态调用接口
     *
     * @param wxUserId
     * @param wxExternalUserid
     * @param type
     * @param page
     * @return
     */
    R getContactTrackListByContactIdWechat(String wxUserId, String wxExternalUserid, Integer type, Page page);

    void saveTrack(Integer employeeId, Integer contactId, EventEnum eventEnum, String content, Integer channel, Integer corpId);

    void saveTrackProd(Integer corpId,Integer employeeId, Integer contactId, EventEnum eventEnum, String content,Integer channel);

    R<Page<ContactClientListVO>> getClientList(String wxUserId, Integer roomId, Page page);

    /**
     * 获取客户信息
     *
     * @param page
     * @param employeeId
     * @return
     */
    IPage<ContactEmployeeTagVO> getContactListByUser(Page page,Integer employeeId);

    List<Map<String,String>> getNoCommunicationMapList(Integer corpId);

    /**
     * 发送消息给成员
     *
     * @param dto
     */
    void getMsgToUser(MsgToEmployeeDTO dto);

    /**
     * 发送消息给成员
     * 场景 客户在公众号进行提问
     * @param dto
     */
    void getGZHMsgToUserByLink(WxGZHDto dto);

    /**
     * 选中成员提醒
     *
     * @param dto
     * @return
     */
    void getUserToContact(MsgToEmployeeDTO dto);

    /**
     *查看聊天记录
     *
     * @param contactId
     * @param employeeId
     * @return
     */
    IPage<List<IndexMsgBO>> getUserMsg(Integer contactId, Integer employeeId,Integer time,Integer type, Page page);

    /**
     * 获取客户未交流数量
     *
     * @param wxUserId
     * @return
     */
    Map<String,Integer> getUserCount(String wxUserId);

    /**
     * 获取客户分页列表-新需求
     * @param page
     * @param dto
     * @return
     */
    Page<ContactPageVO> getPageList(Page page, ContactPageDTO dto);

    /**
     * 获取客户详情
     * @param id
     * @param custNo
     * @return
     */
    ContactNewDetailsVO getContactDetails(Integer id, String custNo);

    /**
     * 根据客户id获取员工与客户信息列表
     * @param id
     * @return
     */
    Page<EmployeeListByContactVO> getEmployeeListByContact(Page page,Integer id);

    /**
     * 当前登录用户机构下的客户同步统计信息
     * @return SyncContactStatisticsVO
     */
    SyncContactStatisticsVO getStatisticsData();

    /**
     * 客户总数趋势
     * @param dto
     * @return SyncContactStatisticsTendencyVO
     */
    List<SyncContactStatisticsTendencyVO> getContactTotalCount(SyncContactDetailsTendencyDTO dto);

    /**
     * CRM客户数趋势
     * @param dto
     * @return SyncContactStatisticsTendencyVO
     */
    List<SyncContactStatisticsTendencyVO> getCrmContactCount(SyncContactDetailsTendencyDTO dto);

    /**
     * 行外客户数趋势
     * @param dto
     * @return SyncContactStatisticsTendencyVO
     */
    List<SyncContactStatisticsTendencyVO> getNonBankContactCount(SyncContactDetailsTendencyDTO dto);

    /**
     * 微信客户数趋势
     * @param dto
     * @return
     */
    List<SyncContactStatisticsTendencyVO> getWxContactCount(SyncContactDetailsTendencyDTO dto);

    /**
     * 企业微信客户数趋势
     * @param dto
     * @return SyncContactStatisticsTendencyVO
     */
    List<SyncContactStatisticsTendencyVO> getQywxContactCount(SyncContactDetailsTendencyDTO dto);

    /**
     * 经理视图-客户信息分页查询
     * @param page
     * @param wxUserId
     * @param name
     * @return
     */
    IPage<ManagerViewCustomerVO> getManagerViewCustomerInfoPage(Page page, String wxUserId, String name);

    /**
     * 通过wxUserId获取该成员所添加的外部联系人的手机号以及外部联系人id列表
     * @param wxUserId
     * @return
     */
    List<Map<String,String>> getMobileAndWxExternalUseridByWxUserId(String wxUserId);

}
